package mysql

import (
	"furni-suite/furnirpc/furnirpc"
	"gorm.io/gorm"
)

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(30);not null;comment:用户名"`
	Password string `gorm:"type:varchar(32);not null;comment:密码"`
}

func (u *User) UserCreate(db *gorm.DB) error {
	return db.Debug().Create(u).Error
}
func UserList(db *gorm.DB) []*furnirpc.UserList {
	var list []*furnirpc.UserList
	db.Debug().Model(&User{}).
		Select(
			"users.id as user_id",
			"users.username as user_name",
			"users.password as password",
		).Find(&list)

	return list

}
